﻿using ArticleClientLib;
using eslib.FileManageLib;
using eslib.tools.config;
using System;
using System.Text.Json.Serialization;

namespace test
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ArticleApi.SetAdminAccount("admin", "nickey2008");
            ArticleApi api = new ArticleApi();


            //uploadImg();

            //version();

            //artSystem();

            //test();

            //syncClassifly();
            //getClassiflyIdColl();

            Console.Write("输入任意键结束");
            Console.ReadKey(true);
        }


        private static void test()
        {
            ArticleApi api = new ArticleApi();
            _ = api.Login("admin", "nickey2008");

            ArticleSyncSystem sys = new();
            var c = sys.ArticleRoot.Classiflies[0];
            LocalArticle art = c.Articles[0];
            art.Delete();
        }



        private static async Task syncClassifly()
        {
            ArticleSyncSystem sync = new();
            //同步分类
            await sync.ClassiflySync();

            //同步软文
            await sync.ArticleSync();
        }


        private static void getClassiflyIdColl()
        {
            ArticleApi api = new ArticleApi();
            var res = api.GetClassiflyArticleIdCollection(1).Result;
            if (res.res)
            {
                List<long> list = res.idColl;       //article列表
            }
        }


        private static void artSystem()
        {
            AritcleSystem sys = new();
            //目录检查 
            var res = sys.Check();
            if (!res.pass)
            {
                Console.WriteLine(res.log);
                return;
            }
            else
            {
                Console.WriteLine("目录检查完成");
            }


            //上传新软文
            var upres = sys.UploadNewArticles().Result;
            if (upres.success)
            {
                Console.WriteLine("新软文上传完成");
            }
            else
            {
                Console.WriteLine("上传异常:");
                Console.WriteLine(upres.msg);
            }
        }




        private static void version()
        {
            ArticleApi api = new ArticleApi();
            var res = api.Version().Result;
        }

    }




}